package com.jsmtr.rms.controller.UserResumeView;

import com.jsmtr.rms.entity.*;
import com.jsmtr.rms.service.IDoResumeService;
import com.jsmtr.rms.service.IUtilService;
import com.jsmtr.rms.utils.EnumTools;
import com.jsmtr.rms.utils.StringTools;
import org.apache.poi.util.StringUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * 查看应聘者简历控制
 * @author: cyx
 * @description:
 * @date: Created in 2019/2/15 11:51
 * @modified by:
 */
@Controller
public class UserResumePostController {
    @Resource
    private IDoResumeService doResumeService;
    @Resource
    private IUtilService utilService;

    //region 查看职位申请表
    @RequestMapping("/UserResume/Application")
    public String Application(HttpServletRequest request, Model model) {
        try {
            DUserResume resume = doResumeService.getDUserResume(request.getParameter("id"));
            if(!StringTools.trimNotEmpty(resume.getJname())) {
                resume.setJname("");
            }else if (resume.getJname().equals("-")) {
                resume.setJname("待定");
            }
            String rid = resume.getId();
            List<DUserEducation> educations = doResumeService.getUserEducation(rid);//教育背景
            List<DUserWorkExperience> workexperiences = doResumeService.getUserWorkExperience(rid); //工作经验
            List<DUserTraining> trainings = doResumeService.getUserTraining(rid); //培训经历

            model.addAttribute("fpath", doResumeService.getConfig("path"));
            model.addAttribute("resume", resume);
            model.addAttribute("edus", educations);
            model.addAttribute("works", workexperiences);
            model.addAttribute("tras", trainings);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/Do/UserResume/application";
    }
    //endregion


}
